Baseball, by the Rules

A trio of Philadelphia Phillies sprint to attempt a catch on a fly ball that is slicing foul.
A Ball in the Air Goes Foul
The vast majority of the time, when a ball in the air goes foul, two things beome clear very quickly: that the ball will, indeed, be foul, and also, if it's going to be caught by anyone, it's going to be caught by a fan, not a fielder. This is your standard-issue foul ball; the ball is declared dead, the umpire throws a new baseball to the pitcher, and the plate appearance continues.
Sometimes, though, the ball stays over the field of play; if it does, and a fielder catches it before it hits either the ground, or any part of the stadium, the batter is ruled out. When we talk about “any part of the stadium,” we are usually talking about netting, specifically the netting that lines the stands to protect fans from certain types of foul balls. If a ball touches that netting before it gets to a fielder’s glove, it’s a foul ball, and any subsequent catch does not count. If a defender makes a play on a catchable foul ball, but does not make the catch, this can result in a missed catch error.
For balls that land near the line and thus need an umpire to weigh in, that umpire indicates a foul ball by holding his hands up, essentially declaring a dead ball. If the ball lands fair, they will point to fair territory, instead.
If a fly ball goes foul without being caught, any runners who were on base have to return to their original base before the next pitch is thrown. If the ball is caught, however, these runners have a chance to advance via “tagging up”. See the explainer on tagging up if you need a refresher on that concept. If a runner tags up and scores, then the batter is credited with a sacrifice fly. In such a circumstance, the batter is not credited with an at-bat, as they have “sacrificed” the at-bat to score the runner. They are credited with a run batted in, however. A runner attempting to advance after a foul fly ball is caught can also potentially be thrown out, especially at the plate, turning the fly ball into a double play.
Fair/foul calls can only be reviewed by replay if the ball lands “behind” the spot where the base umpires usually stand, so calls further down the first- or third-base lines are reviewable, while calls closer to home plate are not. This is important when you are looking at the difference between a very long foul ball, and home run. Balls that may or may not have hit the net before being caught are always reviewable, as are catches on balls that may have actually hit the ground before being caught.
A ball that goes foul but stays in the playing area must be collected and removed from the field before play resumes. If the count had less than two strikes before the pitch, then the foul ball results in a strike. If there were already two strikes, then the count does not advance on a foul ball— unless, of course, the ball was struck foul by a bunt. A bunted foul ball is always a strike, regardless of the count beforehand.